package framelib.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import framelib.common.SessionData;

/**
 * Title:SessionUtil
 * Description:
 * @Create_by:Vince Yu
 * @Create_date:2012-5-7
 * @Last_Edit_By:
 * @Edit_Description
 * @version:ShareWithUs 1.0
 * 
 */
public class SessionUtil {
	
	
	/**
	 * Title:获取session
	 * Description:
	 * @Create_by:Vince Yu
	 * @Create_date:2012-5-7
	 * @Last_Edit_By:
	 * @Edit_Description
	 * @Create_Version:ShareWithUs 1.0
	 */
	public static HttpSession getSession(HttpServletRequest request){
		return request.getSession();
	}
	
	/**
	 * Title:SessionDate
	 * Description:
	 * @Create_by:Vince Yu
	 * @Create_date:2012-5-7
	 * @Last_Edit_By:
	 * @Edit_Description
	 * @Create_Version:ShareWithUs 1.0
	 */
	public static SessionData getSessionData(HttpServletRequest request){
		return (SessionData)request.getSession().getAttribute("sessionData");
	}
	
	/**
	 * Title:从memcached中获取SessionDate
	 * Description:
	 * @Create_by:Vince Yu
	 * @Create_date:2012-5-7
	 * @Last_Edit_By:
	 * @Edit_Description
	 * @Create_Version:ShareWithUs 1.0
	 */
	public static SessionData getSessionDataByMC(HttpServletRequest request, String uid){
		MemcachedClientIF mc = (MemcachedClientIF)(SpringUtil.getWebApplicationContext(
				request.getSession().getServletContext()).getBean("clientMemcached"));
		return (SessionData)mc.get(uid);
	}
	
}
